<%@ page contentType="text/html;charset=UTF-8"%>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
	<title>创建报价单</title>
    <%@ include file="/WEB-INF/views/include/head.jsp"%>
    <script src="${ctxStatic}/js/jquery-1.9.1.min.js"></script>
    <script src="${ctxStatic}/js/DateTimePicker.js"></script>
    <script src="${ctxStatic}/js/layer.js"></script>
    <script src="${ctxStatic}/js/style.js"></script>
    <script src="${ctxStatic}/dateCalendar/WdatePicker.js"></script>
    <link rel="stylesheet" href="${ctxStatic}/css/common.css">
    <link rel="stylesheet" href="${ctxStatic}/css/layerSm.css">
    <script>
    $(function(){
            $(".tabBox ul li").each(function(){
                var index=$(this).index();

                $(".tabBox ul li").eq(0).addClass("active");

                $(this).click(function(){

                    //alert(index);

                    $(this).addClass("active").siblings().removeClass("active");

                    $(".tabBoxSm > .tabSm").eq(index).stop(true).show().siblings().stop(true).hide();
					
					var tableW = $(".tabBoxSm > .tabSm").eq(index).find('.tableHead').width();
					var tabodyH = $(".tabBoxSm > .tabSm").eq(index).find('.tableBody').height();
					var tableScrollH = $(".tabBoxSm > .tabSm").eq(index).find('.tableScroll').height();
					if(tabodyH>tableScrollH){
						$(".tabBoxSm > .tabSm").eq(index).find('.tableScroll').css('width',tableW + 18 + 'px')
					}else{
						$(".tabBoxSm > .tabSm").eq(index).find('.tableScroll').css('width','inherit')
					}

                })

            })

        })
        
        $(document).ready(function(){
        	if ($("#id").val() == null || $("#id").val() == 0) {
        		$("#contractStatus").attr('disabled','disabled');
			}
        	if ($("#ognizationNameB").val() != null && $("#ognizationNameB").val() != '') {
        		showBtn();
			}
        	changeHtml();
        	var form = $("#inputForm");  
            form.validate();//验证指定的表单
        	$("#paymentWay").select2();
        	$("#contractStatus").select2();
        	$("#purchaseType").select2();
       		$("#okButton").click(function(){
        		if (form.valid()) {//如果表单验证成功，则进行提交。 
   	    			$("#showHtml").addClass("showHtml");
	                $("#okHead").show();
	                $("#createHead").hide();  
	                $("#paymentWay").attr('disabled','disabled');
	                $("#contractDateTime").removeClass("laydate-icon");
	                $("#contractEndTime").removeClass("laydate-icon");
	                return false;
              	}
         	});
        });
    
    /* 删除   */
	 
	 function deleteCurrentRow(obj){ 
		 
		 if (confirm("<spring:message code="purchaseContrac_edit_areYouSureDelete"/>")) {
          var tr=obj.parentNode.parentNode.parentNode;  
          var tbody=tr.parentNode;
          tbody.removeChild(tr);
          quantity();
          amount();
		}
	 }
	 /* 计算合计金额 */
	    function myMath(obj) {
	    	var index;
	    	var tr = obj.parentNode.parentNode.parentNode;
	    	index = tr.rowIndex;
				
			var purchasePrice = $("tbody tr").find("input#purchasePrice")[index].value.replace(/,/,"");
			$("tbody tr").find("input#purchasePrice")[index].defaultValue = purchasePrice;
			var purchaseQuantity = $("tbody tr").find("input#purchaseQuantity")[index].value.replace(/,/,"");
			$("tbody tr").find("input#purchaseQuantity")[index].defaultValue = purchaseQuantity;
			var purchaseOther = $("tbody tr").find("input#purchaseOther")[index].value.replace(/,/,"");
			$("tbody tr").find("input#purchaseOther")[index].defaultValue = purchaseOther;
			
			if(purchasePrice==null||purchasePrice==""){
				purchasePrice = 0;
	    	}
			if(purchaseQuantity==null||purchaseQuantity==""){
				purchaseQuantity = 0;
	    	}
			if(purchaseOther==null||purchaseOther==""){
				purchaseOther = 0;
	    	}
			var result = parseFloat(purchasePrice)*parseFloat(purchaseQuantity)+parseFloat(purchaseOther);
			$("tbody tr").find("#purchaseAmount")[index].innerHTML = result;
			formatMoneyThis($("tbody tr").find("#purchaseAmount")[index],3);
			amount();
		}
	 
	  //格式化金额
	    function formatMoneyThis(e, n) {  
	    	var s=$(e).text().replace(",","").trim();
	    	//判断字符串是否为数字     //判断正整数 /^[1-9]+[0-9]*]*$/  
	    	var numberVerification = /^[0-9]+.?[0-9]*$/;   
	        if (numberVerification.test(s)){
	        	n = n > 0 && n <= 20 ? n : 2;  
	            s = parseFloat((s + "").replace(/[^\d\.-]/g, "")).toFixed(n) + "";  
	            var l = s.split(".")[0].split("").reverse(), r = s.split(".")[1];  
	            t = "";  
	            for (var i = 0; i < l.length; i++) {  
	                t += l[i] + ((i + 1) % 3 == 0 && (i + 1) != l.length ? "," : "");  
	            } 
	            $(e).text(t.split("").reverse().join("") + "." + r);
	        }else{
	        	$(e).text("");
	        }
	    }  
	 //计算订料数量 
	 function quantity(){
		 var length = $("tbody tr").length;
		 var sum = 0;
		 for (var i = 0; i < length; i++) {
			 var purchaseQuantity = $("tbody tr").find("input#purchaseQuantity")[i].value.replace(/,/,"");
			 if (purchaseQuantity==null||purchaseQuantity=='') {
				 purchaseQuantity = 0;
			}
			 sum += parseFloat(purchaseQuantity);
		 }
		 $("#contractMaterialQuantity").val(sum);
		 formatMoney($("#contractMaterialQuantity"), 3);
		 
	 }
	 
	//计算订料金额  
	 function amount(){
		 var length = $("tbody tr").length;
		 var sum = 0;
		 for (var i = 0; i < length; i++) {
			 var purchaseAmount = $("tbody tr").find("#purchaseAmount")[i].innerHTML.replace(/,/,"");
			 if (purchaseAmount==null||purchaseAmount=='') {
				 purchaseAmount = 0;
			}
			 sum += parseFloat(purchaseAmount);
		 }
		 $("#contractAmount").val(sum);
		 formatMoney($("#contractAmount"), 3);
		 
	 }
    function showBtn() {
		$("#createMateril").show();
	}
    
    function selectMaterial() {
    	var purchaseType = $("#purchaseType").val();
    	if (purchaseType == "") {
    		tipParent("请选择采购类别");
			return false;
		} 
    	var ognizationNameB = $("#ognizationNameB").val();
    	var ognizationIDB = $("#ognizationIDB").val();
    	popup('900px','584px','${ctx}/purchase/contract/materialList?ognizationNameB='+ognizationNameB+'&purchaseType='+purchaseType+'&ognizationIDB='+ognizationIDB);
	}
    
    /* 保存创建/编辑信息 */
    function saveForm(){
   		$("#contractStatus").removeAttr("disabled");
       	$("#paymentWay").removeAttr("disabled");
       	formUnFormat($("#inputForm"));
       	var params = $("#inputForm").serialize();
       	$.post("${ctx}/purchase/contract/save",params,function(result){
       		/* 弹出提示框,刷新父页面,关闭当前页面 */
       		tipParent(result.message);
       		 window.parent.frames[0].searchListForm();
       		closeWin();
       	},'json');
    }
    /* 获取最大下标 */
    function getIndex() {
    	var statusList = $(".statusIndex").length;
    	var statusNum = 0;
    	if (statusList!=0) {
    		statusNum = $("tbody#listHtml").find("input.statusIndex")[statusList-1].value;
		}
    	return statusNum;
	}
    
    /* 修改合同条款  */
    function updateClause(){
    	var paymentWayText = $("#paymentWayText").val();
    	var paymentWay = $("#paymentWay").val();
    	var paymentWayB = "<spring:message code="purchaseContract_edit_paymentWayB" />";
    	if (paymentWay!="") {
    		var wayHtml = $("#paymentWay").find("option:selected").text();
    		var clauseHtml = $("#contractClause").html();
    		if (paymentWayText!=null && paymentWayText!="") {
    			clauseHtml = clauseHtml.replace(paymentWayText,wayHtml);
    			$("#contractClause").html(clauseHtml);
    			$("#paymentWayText").val(wayHtml);
			}else{
    			clauseHtml = clauseHtml.replace(paymentWayB,wayHtml);
    			$("#contractClause").html(clauseHtml);
    			$("#paymentWayText").val(wayHtml);
			}
		}
    }
    
    function changeHtml(){
    	var purchaseType = $("#purchaseType").val();
    	if (purchaseType == "PURCHASE_TYPE-20") {
			$(".html10").hide();
			$(".html20").show();
            $(".html30").hide();
		}else if (purchaseType == "PURCHASE_TYPE-10") {
			$(".html20").hide();
			$(".html10").show();
            $(".html30").hide();
		}else{
            $(".html20").hide();
            $(".html10").hide();
            $(".html30").show();
        }
    }
    </script>
    <style type="text/css">
    .w-640{
	width:640px;
	}
	.w-65{
	width:65px;
	}
	.showHtml input{
	border:none;
	background-color:inherit;
	color:#333;
	}
    </style>
</head>
<body>
<form id="inputForm">
<!-- 创建编辑头部 -->   
<div id="createHead" class="layerHeader clearfix">
<c:choose>
	   <c:when test="${purchaseContract.id!=null && purchaseContract.id!=''}">
	    <!-- 编辑 --> 
			<p class="headerTitle"><spring:message code="purchaseContract_edit_editContract" /></p>
       </c:when>
       <c:otherwise>
        <!-- 创建 --> 
            <p class="headerTitle"><spring:message code="purchaseContract_edit_createContract" /></p>
       </c:otherwise>
    </c:choose>
	
    <div class="headerButton clearfix">
        <button id="createMateril" style="display: none;" type="button" onclick="selectMaterial()"><spring:message code="purchaseContract_edit_addMaterial"/></button>
        <button type="button" id="okButton"><spring:message code="purchaseContract_edit_ok"/></button>
        <button type="button" onclick="closeWin()"><spring:message code="purchaseContract_edit_cancle"/></button>
    </div>
</div>
<!-- 确认画面头部 -->
<div id="okHead" class="layerHeader clearfix" style="display: none;">	      
             <p class="headerTitle"><spring:message code="purchaseContract_edit_Ok" /></p>    
    <div class="headerButton clearfix">
    <c:choose>
	   <c:when test="${purchaseContract.id!=null && purchaseContract.id!=''}">
	    <!-- 编辑 保存 --> 
	    <shiro:hasPermission name="quotation:message:edit">
			<button type="button" onclick="saveForm();"><spring:message code="common_save" /></button>
		</shiro:hasPermission>
       </c:when>
       <c:otherwise>
        <!-- 创建 保存 --> 
        <shiro:hasPermission name="quotation:message:edit">
            <button type="button" onclick="saveForm();"><spring:message code="common_save" /></button>
            </shiro:hasPermission>
       </c:otherwise>
     </c:choose>
        <!-- 取消 -->
          <button type="button" onclick="closeWin()"><spring:message code="purchaseContract_edit_cancle"/></button>
    </div>
</div>
<div class="tabBox">
    <ul class="clearfix">
     	<li class="active" style="width: 100px"><spring:message code="purchaseContract_edit_contractMessage"/></li>
        <li style="width: 110px"><spring:message code="purchaseContract_edit_materialList"/></li>
    </ul>
    
</div>
<div id="showHtml" class="tabBoxSm">
<c:set value="PURCHASE_TYPE-20" var="typeOfOrder"/>
<c:set value="PURCHASE_TYPE-10" var="typeOfMtm"/>
<c:set value="PURCHASE_TYPE-30" var="typeOfAlert"/>
<input type="hidden" id="id" name="id" value="${purchaseContract.id }">
    <div class="tabSm smOrderBox">
        <div class="items clearfix">
            <div class="col-50 clearfix showHtml haveToBox">
                <!-- 甲方公司  -->
                <p class="tit"><spring:message code="purchaseContract_edit_companyA"/></p>
                <c:choose>
                <c:when test="${purchaseContract.id!=null&&purchaseContract.id!=0 }">
                <input type="hidden" id="ognizationIDA" name="ognizationIDA" value="${purchaseContract.ognizationIDA }">
                	<input value="${purchaseContract.ognizationNameA }" style="width: 315px" disabled="disabled">
                </c:when>
                <c:otherwise>
                <input type="hidden" id="ognizationIDA" name="ognizationIDA" value="${ognization.id }">
                	<input value="${ognization.ognizationName }" style="width: 315px"  disabled="disabled">
                </c:otherwise>
                </c:choose>
                <p class="haveTo">*</p>
            </div>
            <div class="col-50 clearfix haveToBox">
                <!-- 乙方公司   -->
                <p class="tit"><spring:message code="purchaseContract_edit_companyB"/></p>
                <input type="hidden" id="ognizationIDB" name="ognizationIDB" value="${purchaseContract.ognizationIDB }">
                <input type="hidden" id="ognizationShortNameB" name="ognizationShortNameB" value="">
                <input id="ognizationNameB" value="${purchaseContract.ognizationNameB }" style="width: 315px" readonly="readonly" data-rule-required="true" data-msg-required="<spring:message code="purchaseContract_error_msg_ognizationNameB"/>">
                <p class="haveTo">*</p>
                <button type="button" onclick="popup('900px','584px','${ctx}/purchase/contract/ognizationList?ognizationFlag=4&frameFlg=0')"><spring:message code="purchaseContract_edit_select"/></button>
            </div>
        </div>
        <div class="items clearfix">
            <div class="col-50 clearfix showHtml">
                <!-- 住所地  -->
                <p class="tit"><spring:message code="purchaseContract_edit_address"/></p>
                <c:choose>
                <c:when test="${purchaseContract.id!=null&&purchaseContract.id!=0 }">
                	<input value="${purchaseContract.ognizationAddressA }" style="width: 315px"  disabled="disabled">
                </c:when>
                <c:otherwise>
                	<input value="${ognization.ognizationAddress }" style="width: 315px" disabled="disabled">	
                </c:otherwise>
                </c:choose>
            </div>
            <div class="col-50 clearfix">
                <!-- 住所地  -->
                <p class="tit"><spring:message code="purchaseContract_edit_address"/></p>
                <input id="ognizationAddressB" value="${purchaseContract.ognizationAddressB }" style="width: 315px" disabled="disabled">
                
            </div>
        </div>
        <div class="items clearfix">
            <div class="col-50 clearfix">
          		<div class="left clearfix showHtml">
                	<!-- 法人代表  -->
                	<p class="tit"><spring:message code="purchaseContract_edit_legalPerson"/></p>
                <c:choose>
                <c:when test="${purchaseContract.id!=null&&purchaseContract.id!=0 }">
                	<input value="${purchaseContract.legalPersonA }" style="width: 110px" disabled="disabled">
                </c:when>
                <c:otherwise>
                	<input value="${ognization.legalPerson }" style="width: 110px" disabled="disabled">	
                </c:otherwise>
                </c:choose>
            	</div>
            	<div class="right clearfix haveToBox" style="margin-right: 100px;">
                	<!-- 主联系人  -->
                	<p class="tit"><spring:message code="purchaseContract_edit_contactPerson"/></p>
                <c:choose>
                <c:when test="${purchaseContract.id!=null&&purchaseContract.id!=0 }">
                	<input id="contactPersonA" name="contactPersonA"  value="${purchaseContract.contactPersonA }" style="width: 110px" data-rule-required="true" data-msg-required="<spring:message code="purchaseContract_error_msg_contactPersonA"/>">
                </c:when>
                <c:otherwise>
                	<input id="contactPersonA" name="contactPersonA"  value="${ognization.contactPerson }" style="width: 110px" data-rule-required="true" data-msg-required="<spring:message code="purchaseContract_error_msg_contactPersonA"/>">
                </c:otherwise>
                </c:choose>
                <p class="haveTo">*</p>
            	</div>
            </div>
            <div class="col-50 clearfix">
            	<div class="left clearfix">
                	<!-- 法人代表  -->
                	<p class="tit"><spring:message code="purchaseContract_edit_legalPerson"/></p>
                	<input id="legalPersonB" value="${purchaseContract.legalPersonB }" style="width: 110px" disabled="disabled">
            	</div>
            	<div class="right clearfix haveToBox" style="margin-right: 100px;">
                	<!-- 主联系人  -->
                	<p class="tit"><spring:message code="purchaseContract_edit_contactPerson"/></p>
               		<input id="contactPersonB" name="contactPersonB"  value="${purchaseContract.contactPersonB }" style="width: 110px" data-rule-required="true" data-msg-required="<spring:message code="purchaseContract_error_msg_contactPersonB"/>">
               		<p class="haveTo">*</p>
            	</div>
            </div>
        </div>
        <div class="items clearfix">
            <div class="col-50 clearfix showHtml">
            	<div class="left clearfix">
                	<!-- 联系电话  -->
                	<p class="tit"><spring:message code="purchaseContract_edit_contactPhone"/></p>
                <c:choose>
                <c:when test="${purchaseContract.id!=null&&purchaseContract.id!=0 }">
                	<input value="${purchaseContract.contactPhoneA }" style="width: 110px" disabled="disabled">
                </c:when>
                <c:otherwise>
                	<input value="${ognization.contactPhone}" style="width: 110px" disabled="disabled">
                </c:otherwise>
                </c:choose>
            	</div>
            	<div class="right clearfix" style="margin-right: 100px;">
                	<!-- 传真号码  -->
                	<p class="tit"><spring:message code="purchaseContract_edit_contactFax"/></p>
               	<c:choose>
                <c:when test="${purchaseContract.id!=null&&purchaseContract.id!=0 }">
               		<input value="${purchaseContract.contactFaxA }" style="width: 110px" disabled="disabled">
                </c:when>
                <c:otherwise>
                	<input value="${ognization.contactFax }" style="width: 110px" disabled="disabled">
                </c:otherwise>
                </c:choose>
            	</div>
            </div>
            <div class="col-50 clearfix">
            	<div class="left clearfix haveToBox">
                	<!-- 联系电话  -->
                	<p class="tit"><spring:message code="purchaseContract_edit_contactPhone"/></p>
                	<input id="contactPhoneB" name="contactPhoneB"  value="${purchaseContract.contactPhoneB }" style="width: 110px" data-rule-required="true" data-msg-required="<spring:message code="purchaseContract_error_msg_contactPhoneB"/>">
                	<p class="haveTo">*</p>
            	</div>
            	<div class="right clearfix haveToBox" style="margin-right: 100px;">
                	<!-- 传真号码  -->
                	<p class="tit"><spring:message code="purchaseContract_edit_contactFax"/></p>
               		<input id="contactFaxB" name="contactFaxB"  value="${purchaseContract.contactFaxB }" style="width: 110px" data-rule-required="true" data-msg-required="<spring:message code="purchaseContract_error_msg_contactFaxB"/>">
               		<p class="haveTo">*</p>
            	</div>
            </div>
        </div>
        <div class="items clearfix">
            <div class="col-50 clearfix showHtml">
                <!-- 电子邮箱  -->
                <p class="tit"><spring:message code="purchaseContract_edit_contactEmail"/></p>
                <c:choose>
                <c:when test="${purchaseContract.id!=null&&purchaseContract.id!=0 }">
                	<input value="${purchaseContract.contactEmailA }" style="width: 315px" disabled="disabled">
                </c:when>
                <c:otherwise>
                	<input value="${ognization.contactEmail }" style="width: 315px" disabled="disabled">	
                </c:otherwise>
                </c:choose>
            </div>
            <div class="col-50 clearfix haveToBox">
                <!-- 电子邮箱  -->
                <p class="tit"><spring:message code="purchaseContract_edit_contactEmail"/></p>
                <input id="contactEmailB" name="contactEmailB"   value="${purchaseContract.contactEmailB }" style="width: 315px" data-rule-required="true" data-msg-required="<spring:message code="purchaseContract_error_msg_contactEmailB"/>">
            	<p class="haveTo">*</p>
            </div>
        </div>
        <div class=" clearfix" >
        	<!-- 采购合同基本信息  -->
        	<p class="title" style="margin-top: 2px"><spring:message code="purchaseContract_edit_contractBasicMessage"/></p>
        </div>
            	<div class="items clearfix">        	
                    <div class="col-33 clearfix haveToBox">
                    <!-- 付款方式  -->
                        <p class="tit"><spring:message code="purchaseContract_edit_paymentWay"/></p>
                        <c:set value="QUOTATION_TYPE" var="typeList"/>
                        <select id="paymentWay" name="paymentWay" onchange="updateClause();" style="width: 150px" data-rule-required="true" data-msg-required="<spring:message code="purchaseContract_error_msg_paymentWay"/>">
                            <option value=""><spring:message code="quotation_create_selectPlease"/></option>
                        <c:forEach items="${fns:getDictList(typeList) }" var="paymentWay">
                            <option   value="${paymentWay.itemCode}-${paymentWay.itemValue}" <c:if test="${fn:split(purchaseContract.paymentWay,'-')[1] eq paymentWay.itemValue }">selected="selected"</c:if>>${paymentWay.itemName}</option>
                        </c:forEach>
                        </select>
                        <input type="hidden" id="paymentWayText"  value=""/>
                        <p class="haveTo">*</p>
                    </div>
                    <div class="col-33 clearfix haveToBox">
                    <!-- 合同状态  -->
                        <p class="tit"><spring:message code="purchaseContract_edit_contractStatus"/></p>
                        <c:set value="CONTRACT_STAUS" var="statusList"/>
                        <select id="contractStatus" name="contractStatus" style="width: 150px" data-rule-required="true" data-msg-required="">
                        <c:forEach items="${fns:getDictList(statusList) }" var="status">
                            <option   value="${status.itemCode}-${status.itemValue}" <c:if test="${fn:split(purchaseContract.contractStatus,'-')[1] eq status.itemValue }">selected="selected"</c:if>>${status.itemName}</option>
                        </c:forEach>
                        </select>
						<p class="haveTo">*</p>
                    </div>
                    <div class="col-33 clearfix haveToBox">
                    <!-- 采购类别  -->
                        <p class="tit"><spring:message code="purchaseContract_edit_purchaseType"/></p>
                        <c:set value="PURCHASE_TYPE" var="typeList"/>
                        <select id="purchaseType" name="purchaseType" style="width: 150px;" onchange="changeHtml()" data-rule-required="true" data-msg-required="">
                        <option value=""><spring:message code="quotation_create_selectPlease"/></option>
                        <c:forEach items="${fns:getDictList(typeList) }" var="type">
                            <option   value="${type.itemCode}-${type.itemValue}" <c:if test="${fn:split(purchaseContract.purchaseType,'-')[1] eq type.itemValue }">selected="selected"</c:if>>${type.itemName}</option>
                        </c:forEach>
                        </select>
						<p class="haveTo">*</p>
                    </div>
                </div>
        <div class="clearfix">
           <div class="left w-640">
                <div class="items clearfix">        	
                    <div class="col-50 clearfix haveToBox">
                    <!-- 订料总数 -->
                        <p class="tit"><spring:message code="purchaseContract_edit_contractQuantity"/></p>
                        <input  type="tel" id="contractMaterialQuantity" name="contractMaterialQuantity" onblur="formatMoney(this,3);" onfocus="unFormat(this);"  value="<fmt:formatNumber value="${purchaseContract.contractMaterialQuantity }" pattern="#,##0.000##"/>" data-rule-required="true" data-msg-required="<spring:message code="purchaseContract_error_msg_contractMaterialQuantity"/>">
                        <p class="haveTo">*</p>
                    </div>
                    <div class="col-50 clearfix haveToBox">
                    <!-- 订单金额  -->
                        <p class="tit"><spring:message code="purchaseContract_edit_contractAmount"/></p>
                        <input  type="tel" id="contractAmount" name="contractAmount" onblur="formatMoney(this,3);" onfocus="unFormat(this);"  value="<fmt:formatNumber value="${purchaseContract.contractAmount }" pattern="#,##0.000##"/>" data-rule-required="true" data-msg-required="<spring:message code="purchaseContract_error_msg_contractAmount"/>">
                        <p class="haveTo">*</p>
                    </div>
                </div>
                <div class="items clearfix">        	
                    <div class="col-50 clearfix haveToBox">
                    <!-- 签订日期  -->
                        <p class="tit"><spring:message code="purchaseContract_edit_contractDateTime"/></p>
                        <input type="text" onblur="CheckDate(this);" 
								id="contractDateTime" name="contractDateTime"  value="<fmt:formatDate value="${purchaseContract.contractDateTime }" pattern="yyyy-MM-dd" />" data-rule-required="true" data-msg-required="<spring:message code="purchaseContract_error_msg_contractDateTime"/>">
                        <p class="haveTo">*</p>
                    </div>
                    <div class="col-50 clearfix">
                    <!-- 结算日期  -->
                        <p class="tit"><spring:message code="purchaseContract_edit_contractEndDate"/></p>
                        <input type="text" onblur="CheckDate(this);" 
								id="contractEndTime" name=""  value="">
                        <!-- <p class="haveTo">*</p> -->
                    </div>
                </div>
             </div>
             <div class="w-320">
                <div class="items clearfix">     
                    <!-- 特殊说明  -->
                    <p class="tit"><spring:message code="purchaseContract_edit_specialExplain"/></p>
                    <textarea id="specialExplain" name="specialExplain" style="width:220px;height: 70px">${purchaseContract.specialExplain }</textarea>
                </div>
             </div>
        </div>
        <div class="items clearfix haveToBox">        	
            <div class="left w-65 clearfix">
           <!-- 合同条款 -->
                <p class="tit"><spring:message code="purchaseContract_edit_contractClause"/></p>
                <button type="button" onclick="popup('900px','584px','${ctx}/purchase/contract/selectClause?clauseFlag=0')"><spring:message code="purchaseContract_edit_select"/></button>
                </div>
                <div class="clearfix">
                <textarea id="contractClause" name="contractClause" style="width:870px;height: 140px" data-rule-required="true" data-msg-required="<spring:message code="purchaseContract_error_msg_contractClause"/>">${purchaseContract.contractClause }</textarea>
                <p class="haveTo">*</p>
            </div>
        </div>
        <div class="w-500 items clearfix showHtml">
            <div class="items col-50 clearfix">
            <!-- 创建人员 -->
                <p class="tit"><spring:message code="purchaseContract_edit_creator"/></p>
                <c:choose>
                <c:when test="${purchaseContract.id!=null&&purchaseContract.id!=0 }">
                	<input value="${purchaseContract.createBy.firstName }" disabled="disabled">
                </c:when>
                <c:otherwise>
                	<input value="${ognization.createBy.firstName }${ognization.createBy.lastName }" disabled="disabled">
                </c:otherwise>
                </c:choose>
            </div>
            <div class="items col-50 clearfix">
            <!-- 创建时间 -->
                <p class="tit"><spring:message code="purchaseContract_edit_createDate"/></p>
                <c:choose>
                <c:when test="${purchaseContract.id!=null&&purchaseContract.id!=0 }">
                	<input value="<fmt:formatDate value="${purchaseContract.createDate }" pattern="yyyy-MM-dd" />" disabled="disabled">
                </c:when>
                <c:otherwise>
                	<input value="${fns:getDate('yyyy-MM-dd')}" disabled="disabled">
                </c:otherwise>
                </c:choose>
            </div>
            <input type="hidden" id = "clauseTypeTemp" name="clauseType" value="${purchaseContract.clauseType}"/>
        </div>
	</div>
    <div class="tabSm none">
    	<div class="tableArea" >
        	<div class="tableScroll tableScrollSm" >
        		<table cellpadding="0" class="tableHead" >
                    <thead>
                    <tr>
                    	<th><p class="tab-dw"><spring:message code="purchaseContract_edit_operation"/></p></th>
                        <th><p class="tab-wltp"><spring:message code="purchaseContract_edit_materailImage"/></p></th>
                        <th><p class="width-150px"><spring:message code="purchaseContract_edit_materailNameNO"/></p></th>
                        <th><p class="width-50px"><spring:message code="purchaseContract_edit_materailSpec"/></p></th>
                        <th><p class="tab-dw"><spring:message code="purchaseContract_edit_materailSpecUnit"/></p></th>
	                    <th class="html20"><p class="tab-hjje"><spring:message code="purchaseContract_edit_supplierName"/></p></th>
	                    <th class="html20"><p class="tab-dh"><spring:message code="purchaseContract_edit_contractNO"/></p></th>
	                    <th class="html20"><p class="tab-sh"><spring:message code="purchaseContract_edit_reserveQuantity"/></p></th>
	                    <th class="html20"><p class="width-70px"><spring:message code="purchaseContract_edit_realityQuantity"/></p></th>
	                    <th class="html10" style="display: none;"><p class="width-160px"><spring:message code="purchaseContract_edit_customer"/></p></th>
	                    <th class="html10" style="display: none;"><p class="width-160px"><spring:message code="purchaseContract_edit_brand"/></p></th>
                        <th class="html30" style="display: none;"><p class="width-160px"><spring:message code="inventoryWarning_materialAlertQuantity"/></p></th>
                        <th class="html30" style="display: none;"><p class="width-160px"><spring:message code="warningDate"/></p></th>
                        <th><p class="width-70px"><spring:message code="purchaseContract_edit_unitPrice"/></p></th>
                        <th><p class="width-70px"><spring:message code="purchaseContract_edit_quantity"/></p></th>
                        <th><p class="width-70px"><spring:message code="purchaseContract_edit_otherCost"/></p></th>
                        <th><p class="width-70px"><spring:message code="purchaseContract_edit_amount"/></p></th>
                    </tr>
                    </thead>
                </table>
                <table  cellpadding="0" class="tableBody" id="materialTable" >
                    <tbody id="listHtml">
                    <c:forEach items="${purchaseContract.materialList }" var="material" varStatus="status">
                    <tr>
                    	<td><p class="tab-dw"><img src='${ctxStatic}/images/btn-sc.png' style="width: 30px;" onclick='deleteCurrentRow(this)'></p></td>
                        <td><p class="tab-wltp"><c:if test="${material.materialFile!=null && material.materialFile!='' }"><img src="${material.materialFile }" class="wltp"></c:if><c:if test="${material.materialFile==null||material.materialFile=='' }"><img src="${ctxStatic}/images/pic-none.jpg" class="wltp"></c:if></p></td>
                        <td><p class="width-150px">${material.materialCode }<br>${material.materialNameCN }</p></td>
                        <td><p class="width-50px">${material.materialSpec }</p></td>
                        <td><p class="tab-dw">${fns:getDictName(material.materialSpecUnitCD) }</p></td>
                        <c:if test="${purchaseContract.purchaseType eq typeOfOrder }">
	                        <td><p class="tab-hjje">${material.ognizationNameB }</p></td>
	                        <td><p class="tab-dh">${material.contractNO }</p></td>
	                        <td><p class="tab-sh">${material.reserveQuantity }</p></td>
	                        <td><p class="width-70px">${material.realityQuantity }</p></td>
                        </c:if>
                        <c:if test="${purchaseContract.purchaseType eq typeOfMtm }">
	                        <td><p class="width-160px">${material.ognizationNameB }</p></td>
	                        <td><p class="width-160px">${material.brandName }</p></td>
                        </c:if>
                        <c:if test="${purchaseContract.purchaseType eq typeOfAlert }">
                            <td><p class="width-160px">${material.materialAlertQuantity }</p></td>
                            <td><p class="width-160px"></p></td>
                        </c:if>
                        <td><p class="width-70px"><input type="tel" id="purchasePrice" name="materialList[${status.index }].purchaseUnitPrice" value="<fmt:formatNumber value="${material.purchaseUnitPrice }" pattern="#,##0.000##"/>" onchange="myMath(this);" onblur="formatMoney(this,3);" onfocus="unFormat(this);" style="height:65px"/></p></td>
                        <td><p class="width-70px"><input type="tel" id="purchaseQuantity" name="materialList[${status.index }].purchaseReserveQuantity" value="<fmt:formatNumber value="${material.purchaseReserveQuantity }" pattern="#,##0.000##"/>" onchange="myMath(this);quantity();" onblur="formatMoney(this,3);" onfocus="unFormat(this);" style="height:65px"/></p></td>
                        <td><p class="width-70px"><input type="tel" id="purchaseOther" name="materialList[${status.index }].purchaseOtherCost" value="<fmt:formatNumber value="${material.purchaseOtherCost }" pattern="#,##0.000##"/>" onchange="myMath(this);" onblur="formatMoney(this,3);" onfocus="unFormat(this);" style="height:65px"/></p></td>
                        <td><p class="width-70px"><label id="purchaseAmount"><fmt:formatNumber value="${material.purchaseUnitPrice*material.purchaseReserveQuantity + material.purchaseOtherCost }" pattern="#,##0.000##"/></label></p></td>
                        <input type="hidden" class="materialID" name="materialList[${status.index }].materialID" value="${material.materialID}"/>
                        <input type="hidden" name="materialList[${status.index }].contractID" value="${material.contractID}"/>
                        <input type="hidden" name="materialList[${status.index }].indentID" value="${material.indentID}"/>
                        <input type="hidden" name="materialList[${status.index }].styleID" value="${material.styleID}"/>
                        <input type="hidden" name="materialList[${status.index }].materialReservePurchaseID" value="${material.materialReservePurchaseID}"/>
                        <input type="hidden" class="statusIndex" value="${status.index}"/>
                    </tr>
                    </c:forEach>
                    </tbody>
                </table>
                <div id="hiddenHtml"></div>
            </div>
        </div>
    </div>
</div>
</form>
<script>
	window.onload = function(){
			var windowH = window.innerHeight
					||document.documentElement.clientHeight
					||document.body.clientHeight
			$('.tabSm').css({
				'height':windowH - 77,
			});
			$('.tableScrollSm').css({
				'height':windowH - 91
			})
		}
	$('.squareL').on('click', function() {
	    var lastCon = $('.square ol li:last-child').detach();
	    $('.square ol').prepend(lastCon)
	    $('.square ol li:last-child').addClass('active')
	    $('.square ol li:last-child').siblings().removeClass('active')
	})
	$('.squareR').on('click', function() {
	    var lastCon = $('.square ol li:first-child').detach();
	    $('.square ol').append(lastCon)
	    $('.square ol li:last-child').addClass('active')
	    $('.square ol li:last-child').siblings().removeClass('active')
	})
</script>
</body>
</html>
